package com.github.prontera.service;

import java.math.BigDecimal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.prontera.domain.ClientConsume;
import com.github.prontera.domain.enums.ClientConsumeTypeEnum;
import com.github.prontera.persistence.ClientConsumeMapper;
import com.github.prontera.persistence.CrudMapper;

/**
 * 客户端消费表
 */
@Service
public class ClientConsumeService extends CrudServiceImpl<ClientConsume>{
    
	@Autowired
	private ClientConsumeMapper mapper;
	
  	@Autowired
    public ClientConsumeService(CrudMapper<ClientConsume> mapper) {
        super(mapper);
    }

  	/**
  	 * 每日全返利 
  	 */
  	public int dayUpdateRebate(ClientConsume clientConsume){
  		return mapper.dayUpdateRebate(clientConsume);
  	}
  	
  	public boolean insert(long clientId,BigDecimal amount,long productId,ClientConsumeTypeEnum clientConsumeTypeEnum) {
  		ClientConsume clientConsume=new ClientConsume();
  		clientConsume.setClientId(clientId);
  		clientConsume.setAmount(amount);
  		clientConsume.setProductId(productId);
  		clientConsume.setType(clientConsumeTypeEnum);
		return mapper.insert(clientConsume)>0;
	}
  	

}
